package com.wanmait.happyheating.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import com.wanmait.happyheating.pojo.WorkersLog;
import com.wanmait.happyheating.service.WorkersLogService;
import com.wanmait.happyheating.util.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;


@RestController
@RequestMapping("/manage")
public class AdminWorkersLogController {
    @Resource
    private WorkersLogService workersLogService;
    /**
     * 陈宗    2021-06-20
     * Controller的维修人员的日志查询并且分页的方法
     *
     * @param
     * @param
     * @return
     */
    @PostMapping("workersLog")
    public Result workersLog(@RequestBody WorkersLog workersLog, Integer pageNum) {
        //维修人员日志id为0时,设置维修人员日志id为null
        if (workersLog.getId() == 0) {
            workersLog.setId(null);
        }
        //第几页为null时,显示第一页
        if (pageNum == null) {
            pageNum = 1;
        }
        //调用业务逻辑层根据添加时间查询维修员工日志并且分页的方法
        PageInfo<WorkersLog> pageInfo = workersLogService.findPage(pageNum, workersLog);
        return Result.success(pageInfo);
    }

}
